# from selenium import webdriver
# from selenium.webdriver import ActionChains
# import time
#
# url = 'http://www.baidu.com'
#
# # 创建浏览器对象
# driver = webdriver.Chrome()
#
# # 访问百度
# driver.get(url)
#
# # 点击设置
# # el_set = driver.find_element_by_link_text('设置')
# el_set =driver.find_element_by_id("s-usersetting-top")
# el_set.click()
#
# # 点击搜索设置
# el_sset = driver.find_element_by_link_text('搜索设置')
# el_sset.click()
#
# # 定位到保存按钮
# # el_save = driver.find_element_by_css_selector('.prefpanelgo')
# el_save = driver.find_element_by_link_text('保存设置')
# el_save.click()
#
#
# # 进入到弹出框，执行接受
# time.sleep(3)
# # driver.switch_to.alert.accept()
# driver.switch_to.alert.dismiss()
#
#
# time.sleep(5)
# driver.quit()

# from selenium import webdriver
# from selenium.webdriver.support.select import Select
# import time
#
# url = 'http://www.baidu.com'
#
# driver = webdriver.Chrome()
# driver.get(url)
#
# # 定位搜索按钮
# el_so = driver.find_element_by_css_selector('a.pf:nth-child(8)')
# el_so.click()
#
# # 定位搜索设置按钮，并点击
# el_set = driver.find_element_by_css_selector('.setpref')
# el_set.click()

# # 定位下拉框对象
# sel = driver.find_element_by_id('nr')
#
# # 构建选择对象
# selobj = Select(sel)
# # print(selobj)
# # print(dir(selobj))
#
#
# # 显示所有已经选择的选项
# print (selobj.all_selected_options)
# # 显示第一个已经选择的选项
# print (selobj.first_selected_option)
# # 显示所有选项
# print (selobj.options)


# 使用索引选择
# selobj.select_by_index(0)
# time.sleep(5)
# selobj.select_by_index(1)
# time.sleep(5)
# selobj.select_by_index(2)
#
# # 通过值进行选择
# selobj.select_by_value("20")
# time.sleep(2)
# selobj.select_by_value("50")
#
# # 通过可见文本
# selobj.select_by_visible_text('每页显示50条')
# time.sleep(2)
# selobj.select_by_visible_text('每页显示20条')
#
# time.sleep(5)
#
# driver.close()
#
# from selenium import webdriver
# import time
# url = 'https://www.hao123.com/'
#
# driver = webdriver.Chrome()
# driver.get(url)
#
# for i in range(100):
#     # 滚动到固定位置
#     js = 'window.scrollTo(0,%s)'%(100*i)
#     # 滚动到距离顶部指定长度
#     # js = "var q=document.documentElement.scrollTop=%s"%(100*i)
#     driver.execute_script(js)
#     time.sleep(0.1)
#
# time.sleep(5)
# driver.quit()
#
# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
#
# url = 'http://www.baidu.com'
#
# driver = webdriver.Chrome()
# driver.get(url)
#
# # 设置显示等待
# el = WebDriverWait(driver, 60, 0.5).until(EC.presence_of_element_located((By.CSS_SELECTOR,'#lh > a:nth-child(3)')))
#
# print (el.text)
#
# driver.close()
#
# from selenium import webdriver
# import time
# url = 'https://www.amazon.cn/'
#
# driver = webdriver.Chrome()
# driver.get(url)
# # 设置隐式等待
# driver.implicitly_wait(10)
#
# driver.quit()
#
# from selenium import webdriver
#
# driver = webdriver.Firefox()
# driver.get("http://www.youdao.com")
#
# # 获得cookie信息
# cookie= driver.get_cookies()
# # 将获得cookie的信息打印
# print(cookie)
#
# driver.quit()
#
# from selenium import webdriver
#
# driver = webdriver.Chrome()
# driver.get("http://www.youdao.com")
#
# # 向cookie的name 和value中添加会话信息
# driver.add_cookie({'name': 'itcast', 'value': 'itheima'})
#
# # 遍历cookies中的name 和value信息并打印，当然还有上面添加的信息
# for cookie in driver.get_cookies():
#     print("%s -> %s" % (cookie['name'], cookie['value']))
#
# driver.quit()